package com.yto.hrreport.event.buttons {
	import com.yto.hrreport.command.ReportCommand;
	import com.yto.hrreport.event.buttons.superbutton.ButtonEvent;
	
	import flash.events.MouseEvent;
	
	import mx.controls.Alert;
	import mx.controls.TextInput;
	import mx.events.CloseEvent;
	
	public class CancleButtonEvent extends ButtonEvent {
		
		private static var closeEvent : CancleButtonEvent = new CancleButtonEvent();
		private var param : Object;
		private static var parentName : String;
		private var mouseEvent : MouseEvent;
		
		public function CancleButtonEvent() {
			super();
		}
		
		public static function getInstance(parentName : String) : CancleButtonEvent {
			CancleButtonEvent.parentName = parentName;
			return closeEvent;
		}
		
		public function cancleHandler(event : MouseEvent) : void {
			
			mouseEvent = event;
			Alert.show("取消当前操作？" , "提示" , Alert.OK|Alert.CANCEL , hrreport.ui , close );
			
		}
		
		public function close(event : CloseEvent) : void {
			
			param = ReportCommand.getInstance(parentName).initParam("onBoCancle");
			
			if(event.detail == Alert.OK) {
				param.bodyGrid.dataProvider = param.oldBodyData;
				TextInput(param.headCard.getChildByName(parentName + "_txtPeriod")).text = param.oldTxtPeriod;
				updateButtons(mouseEvent , "cancle" , param.headCanvas , true);
			}
			
		}
	}
}